<template>
  <div style="">
    <div class="class-header">
      <div class="class-background">
        <img :src="courseDetail.bgImage" style="width: 100%">
        <div class="class-introduction">
          <Row>
            <i-col span="20">
              <div class="class-title">
                {{ courseDetail.courseName }}
              </div>
              <div class="tutor-info">
                <img src="../../../assets/images/student/tutor-avatar.jpg" class="tutor-avatar">
                <div class="tutor-name">
                  <span class="name-info"> {{ courseDetail.teacherName }}</span>
                  <span class="org-info"> {{ courseDetail.orgName }}</span>
                </div>
                <div class="tutor-label">
                  热心、勤奋、不甘寂寞的程序员
                </div>
              </div>
              <div class="class-live-status">
                <span><Icon type="ios-options" /> 难度：中级</span>
                <span><Icon type="md-people" /> 学习人数：89999222</span>
              </div>
            </i-col>
            <i-col span="4">
              <div class="share">
                <span class="share-button">分享</span>
                <span class="share-wechat"><Icon type="ios-ionitron" /></span>
                <span class="share-qq"></span>
                <span class="share-weibo"></span>
              </div>
            </i-col>
          </Row>
        </div>
      </div>
    </div>
    <div class="class-content">
      <div class="class-select-tab">
        <div class="chapter-menu">
          <span class="chapter-menu-item">课程章节</span>
          <span class="chapter-menu-item">课程公告</span>
        </div>
      </div>
      <div class="chapters">
        <Row>
          <i-col span="18">
            <Card style="width: 100%;min-height: 220px;margin-top: 15px;">
              <p slot="title">课程简介</p>
              <div v-html="courseDetail.notice">
                {{ courseDetail.notice }}
              </div>
            </Card>
            <Card style="width: 100%;min-height: 220px;margin-top: 15px;">
              <div class="chapter">
                <div class="chapter-title">第一章 课程介绍</div>
                <div class="chapter-subtitle">课程介绍</div>
                <a href="">
                  <div class="chapter-item">
                    <Icon type="md-arrow-dropright-circle" style="font-size: 28px;"/>
                    <span>1-1  课程简介</span>
                    <span style="float: right">
                      <Icon type="md-checkmark-circle" />
                    </span>
                  </div>
                </a>
                <a href="">
                  <div class="chapter-item">
                    <Icon type="md-arrow-dropright-circle" style="font-size: 28px;"/>
                    <span>1-2  课程入门</span>
                    <span style="float: right">
                      <Icon type="md-checkmark-circle" />
                    </span>
                  </div>
                </a>
                <a href="">
                  <div class="chapter-item">
                    <Icon type="md-arrow-dropright-circle" style="font-size: 28px;"/>
                    <span>1-3  课程绪论</span>
                    <span style="float: right">
                      <Icon type="md-checkmark-circle" />
                    </span>
                  </div>
                </a>
              </div>
            </Card>
            <Card style="width: 100%;min-height: 220px;margin-top: 15px;">
              <div class="chapter">
                <div class="chapter-title">第二章 Web进阶</div>
                <div class="chapter-subtitle">课程介绍</div>
                <a href="">
                  <div class="chapter-item">
                    <Icon type="md-arrow-dropright-circle" style="font-size: 28px;"/>
                    <span>2-1  表单验证</span>
                    <span style="float: right">
                      <Icon type="md-checkmark-circle" />
                    </span>
                  </div>
                </a>
                <a href="">
                  <div class="chapter-item">
                    <Icon type="md-arrow-dropright-circle" style="font-size: 28px;"/>
                    <span>2-2 使用AOP处理请求(上）</span>
                    <span style="float: right">
                      <Icon type="md-checkmark-circle" />
                    </span>
                  </div>
                </a>
                <a href="">
                  <div class="chapter-item">
                    <Icon type="md-arrow-dropright-circle" style="font-size: 28px;"/>
                    <span>2-3 使用AOP处理请求(中）</span>
                    <span style="float: right">
                      <Icon type="md-checkmark-circle" />
                    </span>
                  </div>
                </a>
                <a href="">
                  <div class="chapter-item">
                    <Icon type="md-arrow-dropright-circle" style="font-size: 28px;"/>
                    <span>2-4 使用AOP处理请求(下）</span>
                    <span style="float: right">
                      <Icon type="md-checkmark-circle" />
                    </span>
                  </div>
                </a>
              </div>
            </Card>
          </i-col>
          <i-col span="6" style="padding-left: 20px;margin-top: 15px;">
            <div class="class-progress">
              <div class="class-progress-title">学习进度</div>
              <Progress :percent="45" status="active" />
              <div class="class-progress-previous">上次学至<span>2-7 单元测试</span></div>
              <div v-if="this.isBoughtCourse === false">
                <router-link :to="{ name: 'order-confirm', query: { courseId : this.courseId}}">
                  <Button class="continue-study" @click="goBuyCourse">购买课程</Button>
                </router-link>
              </div>
              <div v-if="this.isBoughtCourse === true">
                <Button class="continue-study" @click="goBuyCourse">学习课程</Button>
              </div>
              <div class="class-progress-title">课程需知</div>
            </div>
            <Card style="margin-top: 15px;">
              <p slot="title">课程标签</p>
              <div>
                <Tag color="primary">标签一</Tag>
                <Tag color="success">标签二</Tag>
                <Tag color="error">标签三</Tag>
                <Tag color="warning">标签四</Tag>
              </div>
            </Card>
          </i-col>
        </Row>
      </div>


    </div>
  </div>
</template>

<script>
export default {
  name: 'index',
  data () {
    return {
      courseDetail: {
        bgImage: '',
        chaptersListVOS: [],
        courseName: '',
        difficulty: '',
        handcover: '',
        id: '',
        introduction: '',
        labelId: '',
        labelNames: [],
        notice: '',
        orgName: '',
        price: 0,
        studentNumber: 0,
        teacherName: ''
      },
      courseId: '',
      isBoughtCourse: false
    }
  },
  methods: {
    getCourseDetail () {
      let url = '/api/api/student/course/detail'
      let params = {
        courseId: this.$route.query.id
      }
      this.$get(url, params).then((res) => {
        if (res.code === 0) {
          this.courseDetail = res.data
          this.courseId = res.data.id
        }
      })
    },
    getCourseBoughtInfo () {
      let url = '/api/order/findCourse'
      let form = {
        courseId: this.$route.query.id
      }
      this.$get(url, form).then((res) => {
        if (res.data === '1') {
          this.isBoughtCourse = true
        } else {
          this.isBoughtCourse = false
        }
      })
    },
    goBuyCourse () {
    }
  },
  mounted () {
    this.getCourseDetail()
    this.getCourseBoughtInfo()
  }
}
</script>

<style scoped>
  .class-background {
    position: relative;
  }
  .class-introduction {
    position: absolute;
    top: 20px;
    width: 100%;
    padding: 0 5%;
  }
  .class-title {
    margin-top: 4.5rem;
    font-size: 2.2rem;
    color: #fff;
  }
  .tutor-info {
    margin-top: 1.5rem;
  }
  .tutor-avatar {
    border-radius: 50%;
    width: 50px;
    float: left;
  }
  .tutor-name {
    color: #fff;
    margin-left: 70px;
  }
  .name-info {
    font-size: 16px;
    font-weight: bold;
  }
  .org-info {
    font-size: 12px;
  }
  .tutor-label {
    color: #fff;
    margin-left: 70px;
  }
  .class-live-status {
    margin-top: 4rem;
    color: #ffffff;
  }
  .share {
    margin-top: 2.5rem;
    color: #fff;
  }
  .share-button {
    font-size: 20px;
  }
  .class-content {
    width: 100%;
    margin-top: -5px;
  }
  .class-select-tab {
    height: 60px;
    background: white;
    box-shadow:2px 2px 3px rgba(238, 48, 48, 0.07);
  }
  .chapter-menu {
    padding: 0 5%;
    line-height: 60px;
  }
  .chapter-menu-item {
    margin-right: 1.8rem;
  }
  .chapters {
    padding: 0 5%;
  }
  .class-progress {
    padding: 15px;
    width: 100%;
    min-height: 22rem;
    background: #ffffff;
    border-radius: 15px;
    box-shadow:2px 2px 3px 3px #e9e9e9;
  }
  .class-progress-title {
    margin-top: 15px;
  }
  .class-progress-previous {
    font-size: 12px;
    text-align: center;
    margin-top: 5px;
  }
  .continue-study {
    margin-top: 15px;
    color: #ffffff;
    background: #e13d13;
    width: 100%;
    font-size: 20px;
    border-radius: 25px;
    height: 50px;
  }
  .chapter-title {
    font-size: 16px;
    font-weight: bold;
  }
  .chapter-subtitle {

  }
  .chapter-item {
    margin-top: 15px;
    height: 50px;
    width: 100%;
    line-height: 50px;
    padding: 0 8px;
  }
  .chapter a :hover {
    height: 50px;
    line-height: 50px;
    padding: 0 8px;
    color: #db2516;
    background: #fffcc8;
    border-radius: 5px;
  }
</style>
